/**
 * 初始化详情对话框
 */
var SdcBasePlanItemInfoDlg = {
    validateFields: {
    	code: {
            validators: {
                notEmpty: {
                    message: '不能为空'
                }
            }
        },
    	type: {
            validators: {
                notEmpty: {
                    message: '类型不能为空'
                }
            }
        },
    	content: {
            validators: {
                notEmpty: {
                    message: '描述不能为空'
                }
            }
        },
    	param: {
            validators: {
                notEmpty: {
                    message: '医嘱、评估表、文本对象代码或ID不能为空'
                }
            }
        },
    }
};


/**
 * 关闭此对话框
 */
SdcBasePlanItemInfoDlg.close = function() {
    parent.layer.close(parent.layer.getFrameIndex(window.name)); //先得到当前iframe层的索引,再执行关闭   
}

/**
 * 验证数据是否为空
 */
SdcBasePlanItemInfoDlg.validate = function () {
    $('#sdcBasePlanItemInfoForm').data("bootstrapValidator").resetForm();
    $('#sdcBasePlanItemInfoForm').bootstrapValidator('validate');
    return $("#sdcBasePlanItemInfoForm").data('bootstrapValidator').isValid();
}

/**
 * 提交新增
 */
SdcBasePlanItemInfoDlg.addSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('sdcBasePlanItemInfoForm',Sys.backendPath + "/sdc/sdcbaseplanitem/add",function(res) {
        Sys.success(res.message);
    	window.parent.SdcBasePlanItem.table.refresh();
        SdcBasePlanItemInfoDlg.close();
    });
}

/**
 * 提交修改
 */
SdcBasePlanItemInfoDlg.editSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('sdcBasePlanItemInfoForm',Sys.backendPath + "/sdc/sdcbaseplanitem/update",function(res) {
        Sys.success(res.message);
    	window.parent.SdcBasePlanItem.table.refresh();
        SdcBasePlanItemInfoDlg.close();
    });
}
SdcBasePlanItemInfoDlg.setPlanId=function(id) {
    $('#planId').val(id);
}

$(function() {
	Sys.initValidator("sdcBasePlanItemInfoForm", SdcBasePlanItemInfoDlg.validateFields);
});
